home *** CD-ROM | disk | FTP | other *** search
- Program ColorEditor;
-
- uses Crt,
- KPascal, Keyboard, Colors;
-
- var
- tf : boolean;
-
-
- Procedure GetNewChar( var TheChar : char );
- var
- ch : char;
- func : boolean;
- Begin
- Say( 90,12, a_pr+ 'Enter the new character or ESC to quit.' );
- repeat
- ch := GetKey( func );
- until (ch <> #00);
- if (ch <> #27) and (not func) then TheChar := ch;
- End;
-
-
- Procedure DisplayColors( blinking : boolean );
- var
- cntrX, cntrY,
- colornum,
- x, y : byte;
- Begin
- x := 18;
- y := 5;
- if (blinking)
- then colornum := 128
- else colornum := 0;
- for cntrY := 1 to 8
- do begin
- for cntrX := 1 to 16
- do begin
- Say( x,y, SayAttr( colornum )+ '*' );
- Inc( x, 3 );
- Inc( colornum );
- end;
- Inc( y, 2 );
- x := 18;
- end;
- End;
-
-
- Procedure SquareColor( ColorNum : byte );
- var
- col,
- line : integer;
- Begin
- line :=(((ColorNum div 16) + 1) * 2) + 3;
- col := (((ColorNum mod 16) + 1) * 3) + 15;
- Say( col-1, line-1, '`a007'+'┌─┐' );
- Say( col-1, line+1, '`a007'+'└─┘' );
- End;
-
- Procedure UnSquareColor( ColorNum : byte );
- var
- col,
- line : integer;
- Begin
- line :=(((ColorNum div 16) + 1) * 2) + 3;
- col := (((ColorNum mod 16) + 1) * 3) + 15;
- Say( col-1, line-1, SayAttr(a_back)+' ' );
- Say( col-1, line+1, SayAttr(a_back)+' ' );
- End;
-
-
- Procedure GetNewColor( var ColorNum : byte );
- var
- old,
- new : integer;
- ch : char;
- blinking,
- func,
- done : boolean;
- Begin
- if (ColorNum > 127)
- then begin
- new := ColorNum - 128;
- blinking := true;
- end
- else begin
- new := ColorNum;
- blinking := false;
- end;
- DisplayColors( blinking );
- Say( 90,24, 'Press Left/Right/Up/Down arrows to change color' );
- Say( 90,25, 'Press the "+" key to turn blinking on/off' );
- done := false;
- repeat
- SquareColor( new );
- repeat
- ch := GetKey( func );
- until (ch <> #00);
- old := new;
- case func of
- true : case ch of
- #72 : Dec( new, 16 ); {up}
- #80 : Inc( new, 16 ); {down}
- #77 : Inc( new ); {right}
- #75 : Dec( new ); {left}
- end;
- false : case ch of
- #13 : done := true;
- #27 : done := true;
- '+' : blinking := not blinking;
- end;
- end;
- UnSquareColor( old );
- if (new < 0) then Inc( new, 128 );
- if (new > 127) then Dec( new, 128 );
- until done;
- if (ch <> #27)
- then begin
- if (blinking)
- then ColorNum := new + 128
- else ColorNum := new;
- end;
- End;
-
-
- Function AttrByte( theAttr : AttrStr ) : byte;
- var
- Cbyte : byte;
- err : integer;
- Begin
- Val( Copy(theAttr,3,3), Cbyte, err );
- if (err = 0)
- then AttrByte := Cbyte
- else AttrByte := 0;
- End;
-
-
- Procedure DisplayList;
- const
- col = 25;
- var
- line : byte;
- Begin
- line := 5;
- Say( col,line, a_mh+'A. '+a_dh+'Highlighted Data' );
- Inc( line );
- Say( col,line, a_mh+'B. '+a_dl+'Normal Data' );
- Inc( line );
- Say( col,line, a_mh+'C. '+a_mh+'Highlighted Menu Character' );
- Inc( line );
- Say( col,line, a_mh+'D. '+a_ml+'Normal Menu Characters' );
- Inc( line );
- Say( col,line, a_mh+'E. '+a_ms+'Selected Menu Item' );
- Inc( line );
- Say( col,line, a_mh+'F. '+a_mn+'Not Selected Menu Item' );
- Inc( line );
- Say( col,line, a_mh+'G. '+a_st+'Status Line Data' );
- Inc( line );
- Say( col,line, a_mh+'H. '+a_pr+'Input Prompt Question' );
- Inc( line );
- Say( col,line, a_mh+'I. '+a_border+'Border Colors' );
- Inc( line );
- Say( col,line, a_mh+'J. '+a_tm+'Time/Date Colors' );
- Inc( line );
- Say( col,line, a_mh+'K. '+a_err+'Error Messages' );
- Inc( line );
- Say( col,line, a_mh+'L. '+a_ins+'Insert On/Off Display' );
- Inc( line );
- Say( col,line, a_mh+'M. '+a_inp+'Input Editing Field' );
- Inc( line );
- Say( col,line, a_mh+'N. '+a_inp+'Input Editing Character: '+fieldblank );
- Inc( line );
- Say( col,line, a_mh+'O. '+a_ed+'Input Field After Editing' );
- Inc( line );
- Say( col,line, a_mh+'P. Background Color: '+SayAttr(a_back)+'BACKGROUND' );
- Inc( line );
- Say( 90,25, 'ESC to quit' );
- End;
-
-
- Procedure GetWhatToDo;
- var
- ColorByte : byte;
- ch : char;
- func,
- quit : boolean;
- Begin
- quit := false;
- repeat
- ClrScr;
- DisplayList;
- repeat
- ch := GetKey( func );
- until (ch <> #00);
- ClrScr;
- case UpCase(ch) of
- #27 : quit := true;
- 'A' : begin
- ColorByte := AttrByte( a_dh );
- GetNewColor( ColorByte );
- a_dh := SayAttr( ColorByte );
- end;
- 'B' : begin
- ColorByte := AttrByte( a_dl );
- GetNewColor( ColorByte );
- a_dl := SayAttr( ColorByte );
- end;
- 'C' : begin
- ColorByte := AttrByte( a_mh );
- GetNewColor( ColorByte );
- a_mh := SayAttr( ColorByte );
- end;
- 'D' : begin
- ColorByte := AttrByte( a_ml );
- GetNewColor( ColorByte );
- a_ml := SayAttr( ColorByte );
- end;
- 'E' : begin
- ColorByte := AttrByte( a_ms );
- GetNewColor( ColorByte );
- a_ms := SayAttr( ColorByte );
- end;
- 'F' : begin
- ColorByte := AttrByte( a_mn );
- GetNewColor( ColorByte );
- a_mn := SayAttr( ColorByte );
- end;
- 'G' : begin
- ColorByte := AttrByte( a_st );
- GetNewColor( ColorByte );
- a_st := SayAttr( ColorByte );
- end;
- 'H' : begin
- ColorByte := AttrByte( a_pr );
- GetNewColor( ColorByte );
- a_pr := SayAttr( ColorByte );
- end;
- 'I' : begin
- ColorByte := AttrByte( a_border );
- GetNewColor( ColorByte );
- a_border := SayAttr( ColorByte );
- end;
- 'J' : begin
- ColorByte := AttrByte( a_tm );
- GetNewColor( ColorByte );
- a_tm := SayAttr( ColorByte );
- end;
- 'K' : begin
- ColorByte := AttrByte( a_err );
- GetNewColor( ColorByte );
- a_err := SayAttr( ColorByte );
- end;
- 'L' : begin
- ColorByte := AttrByte( a_ins );
- GetNewColor( ColorByte );
- a_ins := SayAttr( ColorByte );
- end;
- 'M' : begin
- ColorByte := AttrByte( a_inp );
- GetNewColor( ColorByte );
- a_inp := SayAttr( ColorByte );
- end;
- 'N' : GetNewChar( fieldblank );
- 'O' : begin
- ColorByte := AttrByte( a_ed );
- GetNewColor( ColorByte );
- a_ed := SayAttr( ColorByte );
- end;
- 'P' : begin
- GetNewColor( a_back );
- TextAttr := a_back;
- end;
- end;
- until quit;
- End;
-
-
-
- BEGIN
- tf := GetColors( 'X' );
- TextAttr := a_back;
-
- GetWhatToDo;
- tf := SaveColors( 'X' );
-
- TextAttr := 07;
- ClrScr;
- END.